package com.yj.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GatewayConfig {
    /**
     * Gateway路由器构建，与yml配置互补，相同path则以此为准
     * @param routeLocatorBuilder
     * @return RouteLocator
     */
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
        return routeLocatorBuilder.routes()
                .route("route01", r -> r.path("/payment/timeout").uri("lb://microservice-provider"))
//                .route("route02", r -> r.path("/order/**").uri("http://localhost:8011"))
//                .route("route03", r -> r.path("/tool/**").uri("https://www.shouce.ren"))
                .build();
    }
}
